export const handleFunctions = ref({})
// 搜索条件 配置
const publicStyle = { style: { width: "180px" } }
export const fieldList = ref([
  {
    field: "plan_no",
    placeholder: "备料单号",
  },
  {
    field: "type",
    type: "select",
    options: {
      placeholder: "备料类型",
      data: [
        { label: "FBA备料", value: 1 },
        { label: "海外仓备料", value: 2 },
        { label: "项目产品备料", value: 3 },
      ],
    },
    ...publicStyle,
  },
  {
    field: "skuRange",
    placeholder: "可批量搜索",
    select: [
      { label: "SKU", value: "sku" },
      { label: "自定义SKU", value: "custom_sku" },
      { label: "ASIN", value: "asin" },
    ],
    selectStyle: { width: "120px" },
    style: { width: "200px" },
  },

  {
    field: "timeRange",
    type: "dateTimeRangeNorm",
    select: [
      { label: "添加时间", value: "created_at" },
      { label: "审核时间", value: "verify_time" },
      { label: "备注生效日期", value: "sale_verify_at" },
      { label: "修改时间", value: "updated_at" },
    ],
    selectStyle: { width: "130px" },
  },
  {
    field: "department_id",
    type: "cascader",
    cascaderType: "department",
    placeholder: "备料部门",
    multiple: true,
    collapseTags: true,
    itemProps: {
      props: {
        emitPath: false,
        multiple: true,
        label: "name",
        value: "id",
        children: "sub",
      },
    },
    ...publicStyle,
  },
])
// 高级搜索 配置1
export const highFieldList = ref([
  {
    label: "计划类型",
    field: "plan_type",
    type: "select",
    originField: "plan_type",
    options: {
      placeholder: "计划类型",
    },
    style: { width: "100%" },
  },
  {
    label: "国家",
    field: "country_id",
    type: "select",
    originField: "country",
    options: {
      placeholder: "国家",
    },
    style: { width: "100%" },
  },
  {
    label: "商品活跃度",
    field: "active",
    type: "select",
    originField: "goods_active",
    options: {
      placeholder: "商品活跃度",
    },
    style: { width: "100%" },
  },
  {
    label: "商品状态",
    field: "sku_status",
    type: "select",
    originField: "sku_status",
    options: {
      placeholder: "商品状态",
    },
    style: { width: "100%" },
  },
  {
    label: "货源状态",
    field: "sku_source_status",
    type: "select",
    originField: "sku_resource_status",
    options: {
      placeholder: "货源状态",
    },
    style: { width: "100%" },
  },
  {
    label: "供应商",
    field: "supplier_id",
    type: "selectV2",
    originField: "supplier",
    itemProps: {
      multiple: true,
      collapseTags: true,
      props: {
        label: "supplier_name",
        value: "s_id",
      },
    },
    style: { width: "100%" },
  },

  {
    field: "verifyRange",
    label: "计划人员",
    type: "cascader",
    placeholder: "计划人员",
    select: [
      { label: "计划人员", value: "plan_verify_user_id" },
      { label: "运营人员", value: "sale_verify_user_id" },
      { label: "采购人员", value: "purchase_user_id" },
    ],
    multiple: true,
    collapseTags: true,
    style: { width: "270px", zIndex: 99999 },
    selectStyle: { width: "130px" },
  },

  {
    field: "userRange",
    label: "添加人员",
    type: "cascader",
    placeholder: "添加人员",
    select: [
      { label: "添加人员", value: "create_by" },
      { label: "审核人员", value: "verify_user" },
    ],
    multiple: true,
    collapseTags: true,
    style: { width: "270px", zIndex: 99999 },
    selectStyle: { width: "130px" },
  },
])

export const batchConfig = reactive({
  editMaterial: {
    title: "新增备料计划",
    formOptions: { inline: true, labelPosition: "top", requireAsteriskPosition: "right" },
    form: {},
    fieldOptions: [
      {
        slot: "OrderDtl",
        show: ({ model }) => !!model?.id,
        style: { width: "100%" },
      },

      {
        field: "type",
        label: "备料类型",
        type: "select",
        options: {
          placeholder: "备料类型",
          data: [
            { label: "FBA备料", value: 1 },
            { label: "海外仓备料", value: 2 },
            { label: "项目产品备料", value: 3 },
          ],
        },
        style: { width: "120px" },
      },

      {
        field: "department_id",
        label: "备料部门",
        type: "cascader",
        cascaderType: "department",
        placeholder: "备料部门",
        itemProps: {
          props: {
            emitPath: false,
            label: "name",
            value: "id",
            children: "sub",
          },
        },
        style: { width: "200px" },
        change: (nodes, form) => {
          form.department_name = nodes?.[0]?.pathLabels?.join("/")
        },
      },
      {
        label: "国家",
        field: "country_id",
        type: "select",
        originField: "amazonSite",
        options: { placeholder: "国家" },

        style: { width: "200px" },
      },
      {
        field: "sku",
        label: "SKU",
        style: { width: "320px" },
      },
      { type: "br" },

      // {
      //   field: "custom_sku",
      //   label: "自定义SKU	",
      //   style: { width: "300px" },
      // },
      {
        slot: "GoodsDtl",
        show: ({ model }) => !!model?.id,
        style: { width: "100%" },
      },
      {
        field: "plan_num",
        label: "备料数量",
        style: { width: "120px" },
      },

      {
        label: "预计交期",
        field: "expect_delivery_time",
        type: "dateTimeRangeNorm",
        itemProps: {
          type: "date",
          shortcuts: [],
          format: "YYYY-MM-DD",
          valueFormat: "YYYY-MM-DD",
        },
        style: { width: "180px" },
      },
      {
        field: "sale_verify_user_id",
        label: "运营审核人员",
        type: "cascader",
        placeholder: "运营审核人员",
        style: { width: "120px" },
      },
      {
        field: "remark",
        label: "备注信息",
        type: "textarea",
        style: { width: "320px" },
        autosize: { minRows: 4, maxRows: 6 },
      },
    ],
    rules: {
      type: [{ required: true, message: "请选择备料类型", trigger: "change" }],
      department_id: [{ required: true, message: "请选择备料部门", trigger: "change" }],
      country_id: [{ required: true, message: "请选择国家", trigger: "change" }],
      sku: [{ required: true, message: "请输入SKU", trigger: "change" }],
      plan_num: [{ required: true, message: "请输入备料数量", trigger: "change" }],
      expect_delivery_time: [{ required: true, message: "请选择预计交期", trigger: "change" }],
      sale_verify_user_id: [{ required: true, message: "请选择运营审核人员", trigger: "change" }],
    },
  },
})
